// Copyright (C) 2005-2008 Jae Stutzman (jaebird@gmail.com)
//
// This file is part of CastGen.
//
// CastGen is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// CastGen is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with CastGen.  If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Configuration;
using System.Diagnostics;
using System.Threading;

namespace CastGen
{
	public class Program
	{
		// used to allow only one instance of the program to run...
		private static Mutex onlyOne;

		private readonly RSS2Generator generator = new RSS2Generator();

		public Program()
		{
			try
			{
				generator.Start();
				System.Threading.Thread.Sleep(Timeout.Infinite);
				generator.Stop();
			}
			finally
			{
				// do any cleanup here...
			}
		}

		static void Main() 
		{
			// create the mutex and if there is not another instance
			// running, go ahead...otherwise exit...
			onlyOne = new Mutex(true, Process.GetCurrentProcess().ProcessName);
			if (onlyOne.WaitOne(0, false))
			{
				new Program();
			}
		}
	}

}
